package com.generic.rangewildcard.superd;

import java.util.ArrayList;
import java.util.List;

import com.generic.rangewildcard.Apple;
import com.generic.rangewildcard.Fruit;
import com.generic.rangewildcard.Jonathan;
import com.generic.rangewildcard.Orange;

public class SuperWildcards2 {

	static List<Apple> apples = new ArrayList<Apple>();
	static List<Fruit> fuilts = new ArrayList<Fruit>();

	static <T> void writeExact(List<T> list, T item) {
		list.add(item);
	}

	static <T> void writeWildcart(List<? super T> list, T item) {
		list.add(item);
	}

	static void f1() {
		writeExact(apples, new Apple());
		writeExact(fuilts, new Apple());
		writeExact(fuilts, new Orange());
		writeExact(fuilts, new Jonathan());
	}

	static void f2() {
		writeWildcart(apples, new Apple());
		writeWildcart(fuilts, new Apple());
		writeWildcart(fuilts, new Orange());
		//writeWildcart(apples, new Orange());
		writeWildcart(fuilts, new Jonathan());
	}

	public static void main(String[] args) {
		try {
			f1();
			f2();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
